import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pwd_keeper/global.dart';
import 'package:pwd_keeper/manager/main_manager.dart';
import 'package:pwd_keeper/manager/pwd_keeper_manager.dart';
import 'package:pwd_keeper/pages/index/gesture_recognition.dart';
import 'package:pwd_keeper/pages/index/index.dart';
import 'package:pwd_keeper/router/application.dart';
import 'package:pwd_keeper/router/routers.dart';

void main() {
  // debugPaintSizeEnabled = true;

  final router = Router();
  Routes.configureRoutes(router);
  Application.router = router;

  WidgetsFlutterBinding.ensureInitialized();
  Provider.debugCheckInvalidValueType = null;
  runApp(
    MultiProvider(
      child: MyApp(),
      providers: [
        ChangeNotifierProvider.value(value: MainManager()..init()),
        ChangeNotifierProvider.value(value: PwdKeeperManager()..init()),
      ],
    ),
  );
}

class MyApp extends StatelessWidget {
  MyApp({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    MainManager _mainManager = Provider.of<MainManager>(context);
    return MaterialApp(
      title: "密码管家",
      onGenerateRoute: Application.router.generator,
      theme: ThemeData(
        brightness: Brightness.light,
        primaryColor: Global.backgroundColor,
      ),
      home: Scaffold(
        body:
            _mainManager.verification ? IndexPage() : GestureRecognitionPage(),
      ),
    );
  }
}
